/*
 * Copyright (C) 2020 The LINN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.juqimiao.linn.command;

import com.juqimiao.linn.transfer.Command;
import com.juqimiao.linn.transfer.Response;

/**
 * 用于执行命令{@link Command}的命令总线接口。
 *
 * <p>所有的命令{@link Command}将通过对应的实现{@link CommandExecutorI}接口的命令执行器进行执行。</p>
 * <p>
 *  例如：
 *  AddCustomerCmd 需要实现一个对应的 AddCustomerCmdExt 命令执行器。
 *  调用的时候只需要:
 *
 *  AddCustomerCmd cmd = new AddCustomerCmd();
 *
 *  commandBus.sent(cmd);
 *
 *  CommandBus将会自动根据Command类型找寻到相应的命令执行器 AddCustomerCmdExt 进行执行.
 *
 * </p>
 *
 * @author  Collin Cai
 */
public interface CommandBusI {

    CommandHub getCommandHub();
    // ---- Method ----------/

    /**
     * 执行一个命令, 发送一个{@link Command}命令到 {@link CommandBusI}中，这个命令将被 {@link CommandExecutorI}执行
     *
     * @param baseCommand 一个自定义的命令对象.
     * @return 一个自定义的响应对象。
     */
    Response send(Command baseCommand);
}